package cn.iocoder.yudao.module.shop.controller.app.jiucase;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.shop.controller.admin.jiucase.vo.ShopJiuCasePageReqVO;
import cn.iocoder.yudao.module.shop.controller.admin.jiucase.vo.ShopJiuCaseRespVO;
import cn.iocoder.yudao.module.shop.convert.jiucase.ShopJiuCaseConvert;
import cn.iocoder.yudao.module.shop.dal.dataobject.jiucase.ShopJiuCaseDO;
import cn.iocoder.yudao.module.shop.service.jiucase.ShopJiuCaseService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Tag(name = "APP - 店铺灸法案例")
@RestController
@RequestMapping("/shop/jiu-case")
@Validated
public class AppShopJiuCaseController {

    @Resource
    private ShopJiuCaseService shopJiuCaseService;

    @GetMapping("/page")
    @Operation(summary = "获得店铺灸法案例分页")
    @PreAuthorize("@ss.hasPermission('shop:jiu-case:query')")
    public CommonResult<PageResult<ShopJiuCaseRespVO>> getJiuCasePage(@Valid ShopJiuCasePageReqVO pageVO) {
        PageResult<ShopJiuCaseDO> pageResult = shopJiuCaseService.getJiuCasePage(pageVO);
        return success(ShopJiuCaseConvert.INSTANCE.convertPage(pageResult));
    }
}
